package com.zuoye.day18;

public class ThreadDemo implements Runnable{

    public String date;
    public Object o11;
    public Object o22;
    public ThreadDemo(String date,Object o1,Object o2) {
        this.date = date;
        this.o11 = o1;
        this.o22 = o2;
    }
    @Override
    public synchronized void run() {
        int count = 0;
        while (count != 10) {
            synchronized (o11) { // c
                synchronized (o22) { // a
                    System.out.println(date); // "A"
                    count++; // 1
                    o22.notify();
                }
                try {
                    if (count == 10) {
                        o11.notify();
                    }else o11.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
